<script type="text/javascript" src="/js/jquery.ajaxfileupload.js"></script>
<div class="page_title"><h1 style="display: inline-block">${project.projectName}</h1>
    <#if project.classification == "0">
        实例题
    <#else>
        设计题
    </#if>
</div>
<div class="panel panel-default">
    <div class="panel-header">
        作业详情
    </div>
    <div class="panel-body">
        <form class="form form-horizontal responsive" novalidate="novalidate">

            <div class="row cl">
                <label class="form-label col-xs-3">作业类型：</label>
                <#--                带文本框-->
                <div class="formControls col-xs-8 mt-5">
                    <#if project.classification == '0'>
                        实例题
                    <#else>
                        设计题
                    </#if>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3">作业描述：</label>
                <div class="formControls col-xs-8 mt-5">
                    <p>${project.projectExpression!'无描述'}</p>
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-3">作业要求word：</label>
                <#--                带文本框-->
                <div class="formControls col-xs-8 mt-5">
                    <#if project.docLocation?? && project.docLocation != "">
                        <a href="/adm/project/file/?fileName=${project.docLocation}"><i
                                    class="Hui-iconfont">&#xe695;</i>下载</a>
                    <#else>
                        无附件
                    </#if>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3">已提交/最大提交次数：</label>
                <div class="formControls col-xs-8 mt-5">
                    <#if project.upTimes < project.upTimesMax>
                        <p style="color: blue">${project.upTimes}/${project.upTimesMax!3} 次</p>
                    <#else>
                        <p style="color: red;">${project.upTimes}/${project.upTimesMax!3} 次</p>
                    </#if>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3">作业上传：</label>
                <#--                带文本框-->
                <div class="formControls col-xs-8">
                    <#if project.status == "1">
                        <span class="btn-upload form-group">
                    <input class="input-text upload-url" type="text" name="demo" id="demo" readonly
                           placeholder="/Users/StupidZhe/IT/VB-T/VB03-T/prg1">
                    <a href="javascript:void();" class="btn btn-primary"><i class="Hui-iconfont">&#xe6dc;</i> 作业提交</a>
                    <input type="file" name="projectFile" class="input-file" id="projectFile">
                </span>
                    <#else>
                        <p style="color: red" class="mt-5"> 不可提交</p>
                    </#if>
                    <#--                    <a href="/adm/project/file/?fileName=${project.demoLocation}"><i class="Hui-iconfont">&#xe695;</i>下载</a>-->
                </div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-xs-offset-3">
                    <input class="btn btn-default" type="button" value="&nbsp;&nbsp;返回&nbsp;&nbsp;"
                           onclick="selectView('/stu/project/', '作业管理');">
                </div>
            </div>
        </form>
        <#if list?? && list?size != 0>
            <table class="table table-border table-bordered table-hover mt-20"
            <thead>
            <tr>
                <th>提交时间</th>
                <th>评估结果</th>
                <th style="width: 60%;">说明</th>
                <th>附件</th>
            </tr>
            </thead>
            <tbody>
            <#list list as bean>
                <tr>
                    <td>${bean.upTime}</td>
                    <td>${bean.result}</td>
                    <td>${bean.judgement}</td>
                    <td>
                        <#if bean_index == 0>
                        <a href="/adm/project/file/?fileName=${bean.location}"><i
                                    class="Hui-iconfont">&#xe695;</i>附件下载</a>
                        </#if>
                    </td>
                </tr>
            </#list>

            </tbody>
            <tfoot>
            </tfoot>
            </table>
        <#else>
            <div class="text-c" style="height: 100px;"><h3>无提交记录.</h3></div>
        </#if>
    </div>
</div>
<script type="text/javascript">
    var projectLocation = '';
    $('#projectFile').ajaxfileupload({
        action: '/stu/project/uploadProject/${project.projectId}',
        valid_extensions: ['zip'],
        // valid_extensions: ['doc', 'docx','pdf','txt'],
        onStart: function () {
            layer.msg("作业上传中，请稍等（由于需要进行编译，等待时间会因源程序差异而不同）", {icon: 4, shade: 0.5, time: 0});
            $("#demo").val($('#projectFile').val());
        },
        onComplete: function (data) {
            setTimeout(function () {
                if (data.success) {
                    projectLocation = data.msg;
                    stupidAjaxGetJson("/stu/project/${project.projectId}",
                        "POST", {projectLocation: projectLocation},
                        function (data) {
                            //todo
                            layer.closeAll();
                            if (data.success) {
                                layer.msg(data.msg, {time: 2000, icon: 1, shadeClose: true, shade: 0.5});
                                selectView("/stu/project/${project.projectId}", "班级详情");
                            } else {
                                layer.msg(data.msg, {time: 2000, icon: 1, shadeClose: true, shade: 0.5});
                            }
                        }
                    );
                } else {
                    layer.closeAll();
                    $("#projectFile").val('');
                    if (data.msg !== undefined) {
                        layer.msg("上传失败：" + data.msg, {time: 0, shadeClose: true, icon: 2, shade: 0.5});
                    } else {
                        layer.msg("上传失败：仅支持zip文件", {time: 0, shadeClose: true, icon: 2, shade: 0.5});
                    }
                }
            }, 1000);
        }
    });

</script>